package de.szut.entity;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import de.szut.impl.ModifierValueDaoImpl;
import de.szut.util.ModifierValueType;

import java.io.Serializable;

/**
 * TODO
 * Created by dzebcuks on 19.08.13.
 */
@DatabaseTable(daoClass = ModifierValueDaoImpl.class)
public class ModifierValue implements Serializable {
    @DatabaseField(generatedId = true)
    private int id;

    /**
     * Percent or absolute
     */
    @DatabaseField(dataType = DataType.ENUM_STRING)
    private ModifierValueType type;

    /**
     * Real value, it is independent from the type of value (percent or absolute)
     * The value may be both, positive or negative.
     */
    @DatabaseField
    private int value;

    @Override
    public boolean equals(Object o) {
        boolean equals = false;
        if (o instanceof ModifierValue) {
            if (this.type.equals(((ModifierValue) o).getType()) && this.getValue() == (
                    (ModifierValue) o).getValue()) {
                equals = true;
            }
        }
        return equals;
    }

    public void addValue(int value){
        this.value += value;
    }

    public ModifierValueType getType() {
        return type;
    }

    public void setType(ModifierValueType type) {
        this.type = type;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}
